package com.tcm.pay.web.controller;

import com.tcm.pay.service.OrderNotifyService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 聚合支付回调
 */
@RequestMapping("/pay")
@RestController
public class OrderNotifyController {

    @DubboReference(version = "0.0.1-alpha", group = "order",check = false, timeout = 3000)
    private OrderNotifyService orderNotifyService;


    /**
     * 微信支付通知
     *
     * @return
     * @throws Exception
     */
    @RequestMapping("/order/wx/notify")
    public String orderWxpay(@RequestParam(name = "Succeed", value = "") String succeed,
                         @RequestParam(name = "BillNo", value = "") String billNo,
                         @RequestParam(name = "OrderNo", value = "") String orderNo,
                         @RequestParam(name = "ChannelNo", value = "") String payChannelNo) throws Exception {

        return orderNotifyService.wxpay(succeed,billNo,orderNo,payChannelNo);
    }

    /**
     * 支付宝支付通知
     *
     * @return
     * @throws Exception
     */
    @RequestMapping("/order/ali/notify")
    public String orderAlipay(@RequestParam(name = "Succeed", value = "") String succeed,
                             @RequestParam(name = "BillNo", value = "") String billNo,
                             @RequestParam(name = "OrderNo", value = "") String orderNo,
                             @RequestParam(name = "ChannelNo", value = "") String payChannelNo) throws Exception {

        return orderNotifyService.alipay(succeed,billNo,orderNo,payChannelNo);
    }


}
